package com.sdp.th.db.th_eq_power.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sdp.th.db.th_eq_info.service.IThEqInfoService;
import com.sdp.th.db.th_eq_power.mapper.ThEqPowerMapper;
import com.sdp.th.db.th_eq_power.service.IThEqPowerService;
import com.sdp.th.entity.ThEqInfo;
import com.sdp.th.entity.ThEqPower;

/**
 * <p>
 * 低电量设备信息 服务实现类
 * </p>
 *
 * @author zsp
 * @since 2025-05-08
 */
@Service
public class ThEqPowerServiceImpl extends ServiceImpl<ThEqPowerMapper, ThEqPower> implements IThEqPowerService {

	@Autowired
	private IThEqInfoService iThEqInfoService;
	
	@Override
	public void insertSmokePower(ThEqPower eqPower) {
		ThEqInfo eqInfo = iThEqInfoService.queryEqInfoByNo(eqPower.getDeviceNo());
		if(eqInfo!=null) {
			eqPower.setDeviceRoom(eqInfo.getDeviceRoom());
			eqPower.setDeviceRegion(eqInfo.getDeviceRegion());
			eqPower.setDeviceName(eqInfo.getDeviceName());
			save(eqPower);
		}
	}

	@Override
	public void removeByDeviceNo(String deviceNo) {
		LambdaQueryWrapper<ThEqPower> lambdaQueryWrapper = new LambdaQueryWrapper<>();
		lambdaQueryWrapper.eq(ThEqPower::getDeviceNo, deviceNo);
		remove(lambdaQueryWrapper);
		
	}

	@Override
	public void removeByDeviceType(String deviceType) {
		LambdaQueryWrapper<ThEqPower> lambdaQueryWrapper = new LambdaQueryWrapper<>();
		lambdaQueryWrapper.eq(ThEqPower::getDeviceType, deviceType);
		remove(lambdaQueryWrapper);
	}
	
	public void removeAll() {
		QueryWrapper<ThEqPower> queryWrapper = new QueryWrapper<>();
		queryWrapper.eq("1", 1);
		remove(queryWrapper);
	}

	
}
